﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class ManejadorError
{
    private Dictionary<int, List<string>> _registrosError = new Dictionary<int, List<string>>();

    public void AgregarFuente(IFuenteError fuenteError)
    {
        fuenteError.Error += new EventHandler(RegistrarError);
        fuenteError.Fuente = _registrosError.Keys.Count;

        _registrosError.Add(fuenteError.Fuente, new List<string>());
    }
    
    public void RegistrarError(object sender, EventArgs e)
    {
        IFuenteError fuenteErrores = (IFuenteError)sender;
        ErrorEventArgs evento = (ErrorEventArgs)e;

        _registrosError[fuenteErrores.Fuente].Add(evento.Error);
    }

    public List<string> ObtenerErrores(IFuenteError fuenteErrores) 
    {
        var lista = from error in _registrosError[fuenteErrores.Fuente] select error;

        return lista.ToList<string>();
    }

}
